namespace CLELCore
{
	static public class Endiness
	{
		public static short ShortLittleToBigEndian(byte b1,byte b2)
		{
			return (short)((b2<<8) | b1);
		}
		
		public static int IntLittleToBigEndian(byte b1,byte b2,byte b3,byte b4)
		{
			return ((b4<<24) | (b3<<16) | (b2<<8) | b1);
		}

		public static uint UnsignedIntLittleToBigEndian(byte b1,byte b2,byte b3,byte b4)
		{
			int ret = IntLittleToBigEndian(b1,b2,b3,b4);
			return (uint)ret;
		}
		
		public static long LongLittleToBigEndian(byte b1,byte b2,byte b3,byte b4,byte b5,byte b6,byte b7,byte b8)
		{
			long top = (long)((b8 << 24) | (b7 << 16) | (b6 << 8) | b5);
			long bottom = (long)((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
			return (top<<32)|bottom;
		}

		public static short ShortBigToLittleEndian(byte b1,byte b2)
		{
			return (short)((b1<<8) | b2);
		}

		public static int IntBigToLittleEndian(byte b1,byte b2,byte b3,byte b4)
		{
			return ((b1<<24) | (b2<<16) | (b3<<8) | b4);
		}
		
		public static uint UnsignedIntBigToLittleEndian(byte b1,byte b2,byte b3,byte b4)
		{
			int ret = IntBigToLittleEndian(b1,b2,b3,b4);
			return (uint)ret;
		}

		public static long LongBigToLittleEndian(byte b1,byte b2,byte b3,byte b4,byte b5,byte b6,byte b7,byte b8)
		{
			long top = (long)((b1 << 24) | (b2 << 16) | (b3 << 8) | b4);
			long bottom = (long)((b5 << 24) | (b6 << 16) | (b7 << 8) | b8);
			return (top<<32)|bottom;
		}
	}
}
